/*
 *
 *  * Copyright (c) 2016. For Intelligent Group.
 *
 */

package com.intelligent.ispc.r.dto;

import java.math.BigDecimal;

/**
 * Created by Peter on 2016/7/15.
 */
public class AnalysisParamDto {
    private int groupNum;
    private double[] analysisData;
    private Integer digitNum;

    private Double uslValue;
    private Double lslValue;
    private Double centerValue;

    /**
     * Get the data count.
     *
     * @return count
     */
    public int getDataCount() {
        if (analysisData == null) {
            return 0;
        } else {
            return analysisData.length;
        }
    }

    public Double getUslValue() {
        return uslValue;
    }

    public void setUslValue(Double uslValue) {
        this.uslValue = uslValue;
    }

    public Double getLslValue() {
        return lslValue;
    }

    public void setLslValue(Double lslValue) {
        this.lslValue = lslValue;
    }

    /**
     * Get Center Value.
     * center = usl / lsl
     *
     * @return value
     */
    public Double getCenterValue() {
        if (uslValue == null || lslValue == null) {
            return null;
        }
        BigDecimal usl = new BigDecimal(uslValue.toString());
        BigDecimal lsl = new BigDecimal(lslValue.toString());
        BigDecimal center = usl.add(lsl).divide(new BigDecimal("2"));

        return center.doubleValue();
    }

    public void setCenterValue(Double centerValue) {
        this.centerValue = centerValue;
    }

    public int getGroupNum() {
        return groupNum;
    }

    public void setGroupNum(int groupNum) {
        this.groupNum = groupNum;
    }

    public double[] getAnalysisData() {
        return analysisData;
    }

    public void setAnalysisData(double[] analysisData) {
        this.analysisData = analysisData;
    }

    public Integer getDigitNum() {
        return digitNum;
    }

    public void setDigitNum(int digitNum) {
        this.digitNum = digitNum;
    }
}
